package com.mbc.controller;


import com.github.pagehelper.PageInfo;
import com.mbc.comment.Result;
import com.mbc.dto.StrayAnimalInformationCommentsSectionDTO;
import com.mbc.dto.StrayAnimalInformationDTO;
import com.mbc.service.StrayAnimalInformationService;
import com.mbc.vo.StrayAnimalInformationCommentsSectionVO;
import com.mbc.vo.StrayAnimalInformationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 云助流量动物信息 前端控制器
 * </p>
 *
 * @author suimeng
 * @since 2024-06-06
 */
@RestController
@RequestMapping("/stray-animal-information")
@Api(tags = "云助流量动物信息接口")
public class StrayAnimalInformationController {

    @Autowired
    private StrayAnimalInformationService informationService;

    /**
     * 插入动物信息
     *
     * @param userId         用户 ID
     * @param informationDTO 信息 DTO
     * @return {@link Result }<{@link Boolean }>
     */
    @PostMapping("/insertAnimalInformation/{userId}")
    @ApiOperation("新增云助流量动物信息")
    public Result<Boolean> insertAnimalInformation(@PathVariable Integer userId,
                                                   @RequestBody StrayAnimalInformationDTO informationDTO) {
        return Result.success(informationService.insertAnimalInformation(userId, informationDTO));
    }

    /**
     * 新增流浪动物信息评论
     *
     * @param userId     用户 ID
     * @param animalId   动物 ID
     * @param sectionDTO DTO 部分
     * @return {@link Result }<{@link Boolean }>
     */
    @PostMapping("insertStrayAnimalInformationCommentSection/{userId}/{animalId}")
    @ApiOperation("新增流浪动物信息评论")
    public Result<Boolean> insertStrayAnimalInformationCommentSection(@PathVariable Integer userId,
                                                                      @PathVariable Integer animalId,
                                                                      @RequestBody StrayAnimalInformationCommentsSectionDTO sectionDTO) {
        return Result.success(informationService.insertStrayAnimalInformationCommentSection(userId, animalId,
                sectionDTO));
    }

    /**
     * 新增宠物标签
     *
     * @param labelId 标签 ID
     * @param label   标签
     * @return {@link Result }<{@link Boolean }>
     */
    @PostMapping("/insertAnimalLabel/{labelId}")
    @ApiOperation("新增宠物标签")
    public Result<Boolean> insertAnimalLabel(@PathVariable Integer labelId, @RequestParam String label) {
        return Result.success(informationService.insertAnimalLabel(labelId, label));
    }

    /**
     * 分页查询流浪动物信息评论区
     *
     * @param animalId 动物 ID
     * @param page     页
     * @param size     大小
     * @return {@link Result }<{@link PageInfo }<{@link StrayAnimalInformationCommentsSectionVO }>>
     */
    @GetMapping("/selectStrayAnimalInformationCommentSection/{animalId}")
    @ApiOperation("分页查询流浪动物信息评论区")
    public Result<PageInfo<StrayAnimalInformationCommentsSectionVO>> selectStrayAnimalInformationCommentSection(@PathVariable Integer animalId,
                                                                                                                @RequestParam(defaultValue = "1") Integer page,
                                                                                                                @RequestParam(defaultValue = "10") Integer size) {
        PageInfo<StrayAnimalInformationCommentsSectionVO> list =
                informationService.selectStrayAnimalInformationCommentSection(animalId, page, size);
        return Result.success(list);
    }

    /**
     * 查询云助动物信息
     *
     * @param animalId 动物 ID
     * @return {@link Result }<{@link StrayAnimalInformationVO }>
     */
    @GetMapping("/selectAnimalInformation/{animalId}")
    @ApiOperation("查询云助动物信息")
    public Result<StrayAnimalInformationVO> selectAnimalInformation(@PathVariable Integer animalId) {
        StrayAnimalInformationVO informationVO = informationService.selectAnimalInformation(animalId);
        return Result.success(informationVO);
    }

    /**
     * 更新点赞数=
     *
     * @param animalId 动物 ID
     * @param status   地位
     * @return {@link Result }<{@link Boolean }>
     */
    @PostMapping("/updateNumberOfLikes/{animalId}")
    @ApiOperation("更新点赞数")
    public Result<Boolean> updateNumberOfLikes(@PathVariable Integer animalId, @RequestParam Integer status) {
        return Result.success(informationService.updateNumberOfLikes(animalId, status));
    }

    /**
     * 更新动物信息
     *
     * @param animalId             动物 ID
     * @param animalInformationDTO
     * @return {@link Result }<{@link Boolean }>
     */
    @PostMapping("/updateAnimalInformation/{animalId}")
    @ApiOperation("修改云助动物信息")
    public Result<Boolean> updateAnimalInformation(@PathVariable Integer animalId,
                                          @RequestBody StrayAnimalInformationDTO animalInformationDTO) {

        return Result.success(informationService.updateAnimalInformation(animalId,animalInformationDTO));
    }

    /**
     * 删除评论
     *
     * @param animalId 动物 ID
     * @param userId   用户 ID
     * @return {@link Result }<{@link Boolean }>
     */
    @PostMapping("/deleteStrayAnimalInformationCommentSection/{animalId}/{userId}")
    @ApiOperation("删除评论")
    public Result<Boolean> deleteStrayAnimalInformationCommentSection(@PathVariable Integer animalId,
                                                                      @PathVariable Integer userId) {
        return Result.success(informationService.deleteStrayAnimalInformationCommentSection(animalId, userId));
    }

    /**
     * 删除动物信息
     *
     * @param animalId 动物 ID
     * @return {@link Result }<{@link Boolean }>
     */
    @PostMapping("/deleteAnimalInformation/{animalId}")
    @ApiOperation("删除云助动物信息")
    public Result<Boolean> deleteAnimalInformation(@PathVariable Integer animalId) {
        return Result.success(informationService.deleteAnimalInformation(animalId));
    }
}
